package com.kehutong.material.entity;

import java.util.ArrayList;
import java.util.List;
import org.coraframework.bean.valid.CheckField;
import org.coraframework.json.annotation.JSONField;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;
import org.coraframework.orm.annotation.UnSave;

/**
 * 问题库
 * 
 * @author liuzhen (liuxing521a@163.com)
 * @createTime 2020年5月14日 上午9:17:55
 */
@Table(value="t_question_platform", comment="平台问题库")
public class QuestionPlatform extends Entity {

	private static final long serialVersionUID = 2621767404234437110L;

	protected QuestionPlatform(String id) {
		super(id);
		this.deleted = Boolean.FALSE;
	}

	@CheckField("上级不能为空")
	@Column(comment="上级")
	private String pid;

	@CheckField("问题不能为空")
	@Column(length=255, comment="问题")
	private String name;

	@CheckField("答案不能为空")
	@Column(length=255, comment="答案")
	private String answer;
	
	@Column(comment="是否文件夹")
	private boolean isFolder;
	
	@JSONField(serialize = false)
	@Column(comment="逻辑删除")
	private Boolean deleted;

	@UnSave
	private List<QuestionPlatform> childList;


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAnswer() {
		return answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}
	
	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public boolean isFolder() {
		return isFolder;
	}

	public void setFolder(boolean isFolder) {
		this.isFolder = isFolder;
	}

	public void setIsFolder(boolean isFolder) {
		this.isFolder = isFolder;
	}

	public void addChild(QuestionPlatform question) {
		if (childList == null) {
			childList = new ArrayList<>();
		}
		childList.add(question);
	}

	public List<QuestionPlatform> getChildList() {
		return childList;
	}

	public void setChildList(List<QuestionPlatform> childList) {
		this.childList = childList;
	}
}
